#include <iostream>
#include <unistd.h>
#include <fcntl.h>
using namespace std;

#include <purewell/file.hpp>
#include <purewell/memory.hpp>
using namespace purewell;

int
main(int argc, char* argv[])
{
	PWNamedFile file;
	if ( !file.initialize(__FILE__, O_RDONLY, 0777) )
	{
		cerr << "failed to open file: " << __FILE__ << endl;
		return 0;
	}

	PWMemory* mem(PWMemory::create(10, file, 0, PWMEM_OMODE_READ));
	if ( NULL == mem )
	{
		cerr << "failed to create memory" << endl;
		return 0;
	}

	cerr.write((const char*)(*mem)(), mem->getSize()) << endl;

	PWMemory::release(mem);

	return 0;
}

